#include "CylinderP.h"


CylinderP::CylinderP(float base, float top, float height, float slices, int stacks, Material* mat, Texture *tex):Primitive(mat,tex)
{
	this->base=base;
	this->top=top;
	this->height=height;
	this->slices=slices;
	this->stacks=stacks;
	glQ = gluNewQuadric();
	gluQuadricDrawStyle(glQ, GLU_FILL);		
	gluQuadricNormals(glQ, GLU_SMOOTH);		
	gluQuadricOrientation(glQ, GLU_OUTSIDE);
	gluQuadricTexture(glQ, GL_TRUE);
}

void CylinderP::act(float texLS, float texLT)
{
	float ls,lt;
	if(tex->inheritTex){
		ls=texLS;
		lt=texLT;
	}
	else{
		ls=getTex()->getLengthS();
		lt=getTex()->getLengthT();
	}

	getMat()->act();
	getTex()->act();


	
	glPushMatrix();		
	glRotated(180,0,1,0);
	gluDisk(glQ,0,base,slices,stacks);
	glPopMatrix();
	glPushMatrix();	
	gluCylinder(glQ,base,top,height,slices,stacks);
	glTranslated(0,0,height);
	gluDisk(glQ,0,top,slices,stacks);
	glPopMatrix();
}
